import requests
from configs.config import Host
import hashlib
import json
def get_Md5(psd):  #md5加密
    md5=hashlib.md5()
    md5.update(psd.encode('utf-8'))
    return md5.hexdigest()

class Login:
    def login(self,indata,getToken=False):
        url=f"{Host}/account/sLogin"
        #indate=json.loads(indate)  #字符串（json）转字典
        indata['password']=get_Md5(indata['password'])
        payload = indata
        rep=requests.post(url,data=payload)
        if getToken:
            return rep.json()['data']['token']
        else:
            return rep.json()

if __name__ == '__main__':
    print(Login().login({"username":"ma0348","password":"96168"}))